package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.SystemMessage;
import cn.wolfcode.trip.base.mapper.SystemMessageMapper;
import cn.wolfcode.trip.base.mapper.TravelMapper;
import cn.wolfcode.trip.base.mapper.TravelcontentMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ISystemMessageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemMessageServiceImpl implements ISystemMessageService {
    @Autowired
    private TravelMapper travelMapper;
    @Autowired
     private TravelcontentMapper travelcontentMapper;
    @Autowired
     private SystemMessageMapper systemMessageMapper;


    @Override
    public PageInfo<SystemMessage> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<SystemMessage> list=systemMessageMapper.selectForList(qo);
        return new PageInfo<>(list);
    }

    @Override
    public Integer querySystemMessageCount(Long uid) {
        Integer count = systemMessageMapper.listSystemMessageCountByStatus(uid);
        return count;
    }

    @Override
    public SystemMessage queryOneForId(Long id) {
        SystemMessage systemMessage = systemMessageMapper.selectOneForId(id);
        return systemMessage;
    }

    @Override
    public void deleteLetter(Long id) {
        systemMessageMapper.deleteByPrimaryKey(id);
    }
    @Override
    public void changeStatus(Long uid) {
        systemMessageMapper.changeStatus(uid);
    }
}
